package com.bwie.controller;

import com.bwie.domain.Goods;
import com.bwie.domain.Groupbuyingactivity;
import com.bwie.domain.GroupbuyingactivityGoods;
import com.bwie.domain.TOrder;
import com.bwie.server.UserServer;
import com.bwie.service.GoodsService;
import com.bwie.service.GroupbuyingactivityGoodsService;
import com.bwie.service.GroupbuyingactivityService;
import com.bwie.service.TOrderService;
import com.bwie.utils.R;
import com.bwie.vo.GroupVo;
import com.bwie.vo.PageInfoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * TODO
 *
 * @Description
 * @Author 36167
 * @Date 2025/3/19 10:26
 **/


@RestController
@RequestMapping("/group")
public class GroupController {

    @Autowired
    UserServer userServer;

    @Autowired
    GoodsService goodsService;

    @Autowired
    GroupbuyingactivityService groupbuyingactivityService;

    @Autowired
    GroupbuyingactivityGoodsService groupbuyingactivityGoodsService;


    @Autowired
    TOrderService orderService;


    @PostMapping("/getuser/{uid}")
   public R getuser(@PathVariable Integer uid){
      return   userServer.getuser(uid);
    }

    @GetMapping("/grouplist")
    public R grouplist(PageInfoVo pageInfoVo){
        return groupbuyingactivityService.grouplist(pageInfoVo);
    }


    @GetMapping("/goodslist")
    public R goodslist(){
        return goodsService.goodslist();
    }


    @PostMapping("/goodsadd")
    public R goodsadd(@RequestBody Goods goods){
        return goodsService.goodsadd(goods);
    }

    @PostMapping("/add")
    public R add(@RequestBody GroupbuyingactivityGoods goods){
      return groupbuyingactivityGoodsService.add(goods);
    }

    @GetMapping("/getgoods")
    public R getgoods(Integer id){
        return goodsService.getgoods(id);
    }

    @GetMapping("/goodslist1")
    public R goodslist1(Integer id){
        return goodsService.goodslist1(id);
    }

    @PostMapping("/join/{uid}/{gid}/{goodsid}")
    public R join(@PathVariable Integer uid,@PathVariable Integer gid,@PathVariable Integer goodsid){
        return groupbuyingactivityService.join(uid,gid,goodsid);
    }


    @PostMapping("/groupadd")
    public R groupadd(@RequestBody Groupbuyingactivity groupbuyingactivity){
        System.out.println(groupbuyingactivity);
       return groupbuyingactivityService.groupadd(groupbuyingactivity);
    }

    @PostMapping("/orderadd")
    public R orderadd(@RequestBody TOrder tOrder){
       return orderService.orderadd(tOrder);
    }

    @GetMapping("/orderlist")
    public R orderlist(){
        return orderService.orderlist();
    }

    @GetMapping("/xd")
    public R xd(Integer id){
        return orderService.xd(id);
    }

    @GetMapping("/tk")
    public R tk(Integer id){
        return orderService.tk(id);
    }



}
